import { PageConfig } from 'next';
import anylogger from 'anylogger';
import '@mmstudio/an000042';
import an48 from '@mmstudio/an000048';
import { tbactivityinformation } from '../../../atoms/db';

const logger = anylogger('pages/api/activity/avtivity.api');

export type IData = ITbactivityinformation;


export type Result = {
	data: IData;
};

export type Query = {
	/**
	 * 活动id
	 */
	aid: string;
}

/**
 * 活动信息-详情
 */
const handler = an48<Result>();

handler.get(async (req, res) => {
	try {
		logger.debug('msg query:', req.query);
		const { aid } = req.query as Query;
		//获取数据
		const dtData = tbactivityinformation();
		const d = await dtData.first('*').where({
			aid
		});
		//返回数据
		res.status(200).json({ data: d });
	} catch (error) {
		logger.error(error);
		logger.trace(error);
		res.status(200).json({
			data: {} as IData
		});
	}
});

export const config = {} as PageConfig;

export default handler;
